<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center forgotPassword_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub forgotPassword_fd0_0'>
          <view class='flex flex-wrap align-center forgotPassword_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  forgotPassword_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
          </view>
          <view class='flex flex-wrap align-center justify-end forgotPassword_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout forgotPassword_flex_1">
        <view class='flex flex-wrap align-center justify-center forgotPassword_fd1_0'>
          <image class='forgotPassword_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"1.png"'></image>
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd1_1' v-if=" type=='email'">
          <image class='forgotPassword_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"59.png"'></image>
          <benben-input class='flex-sub forgotPassword_fd1_1_c1' type="text" :placeholder="`请输入邮箱号`" confirm-type="done"
            v-model="account" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" />
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd1_1' v-if=" type=='mobile'">
          <image class='forgotPassword_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"55.png"'></image>
          <view class='flex flex-wrap align-center forgotPassword_fd1_2_c1' @click.stop="pickerDiy1704874099380=true">
            <text class='forgotPassword_fd1_2_c1_c0'>+{{area_code}}</text>
            <image class='forgotPassword_fd1_2_c1_c1' mode="aspectFit" :src='STATIC_URL+"56.png"'></image>
          </view>
          <benben-input class='flex-sub forgotPassword_fd1_1_c1' type="number" :placeholder="`请输入手机号`" v-model="account"
            confirm-type="done" :maxlength="11" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" />
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd1_3' v-if=" type=='email'">
          <image class='forgotPassword_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"57.png"'></image>
          <benben-input class='flex-sub forgotPassword_fd1_1_c1' type="number" :placeholder="`请输入验证码`" v-model="code"
            confirm-type="done" :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" />
          <benben-send-verification-code key='1704163730005' ref="vCode1704163730005" class=' forgotPassword_fd1_3_c2'
            after-text='后重新获取' before-text='获取验证码' emptye-text='请输入邮箱号' validate-text='请输入正确邮箱号' account-type='email'
            :auto='true' type='2' :phone="account"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd1_3' v-if=" type=='mobile'">
          <image class='forgotPassword_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"57.png"'></image>
          <benben-input class='flex-sub forgotPassword_fd1_1_c1' type="number" :placeholder="`请输入验证码`" v-model="code"
            confirm-type="done" :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" />
          <benben-send-verification-code key='1704160102988' ref="vCode1704160102988" class=' forgotPassword_fd1_3_c2'
            :areacode="area_code" after-text='后重新获取' before-text='获取验证码' emptye-text='请输入账号' validate-text='请输入正确账号'
            account-type='phone' :auto='true' type='2' :phone="account"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd1_3'>
          <image class='forgotPassword_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"58.png"'></image>
          <benben-flex-password-diy v-model="password" class-name="flex flex align-center forgotPassword_fd1_5_c1"
            :placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
            placeholder-style="color:#999;font-size:28rpx">
            <template #show>
              <text class='fu-iconfont2  forgotPassword_fd1_5_c1_icon1' data-type="show">&#xE837;</text>
            </template>
            <template #hide>
              <text class='fu-iconfont2  forgotPassword_fd1_5_c1_icon2' data-type="hide">&#xEBCC;</text>
            </template>
          </benben-flex-password-diy>
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd1_6' @click.stop="forgotPasswordFunc">
          <button class='forgotPassword_fd1_6_c0'>确定</button>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
    <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1704874099380" :value.sync='area_code'
      :options='areaList' mode='selector' :mask-show='true' :timeout='true' :picker-height='88' default-type='area_code'
      :default-props='{"label":"area_name","value":"area_code"}'>
      <template #picker-header>
        <view class='flex flex-wrap align-center justify-between myProfile_picker2_0'>
          <text class='myProfile_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
          <text>选择区号</text>
          <text class='myProfile_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
        </view>
      </template>
    </benben-picker>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        mobile: '',
        email: '',
        "fd1_3_c2": "mobile",
        "fd1_4_c2": "mobile",
        "fd1_5_c1": "",
        "password": "",
        "account": "",
        "code": "",
        "type": "mobile",
        pickerDiy1704874099380: false,
        areaList: [],
        area_code: '',
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        type
      } = options
      if (type !== undefined) this.type = type
      this.getArea()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      getArea() {
        this.$api.post(global.apiUrls.post65e6e32934885).then(res => {
          if (res.data.code == 1) {
            this.areaList = res.data.data
            this.area_code = this.areaList[0].area_code
          }
        })
      },
      //忘记密码
      async forgotPasswordFunc() {
        if (this.type == 'email') {
          if (!validate(this.account, 'require')) {
            this.$message.info('邮箱不能为空');
            return false;
          }
          if (!validate(this.account, 'emailzh')) {
            this.$message.info('请输入正确的邮箱号');
            return false;
          }
          // this.account = this.account
        } else if (this.type == 'mobile') {
          if (!validate(this.account, 'require')) {
            this.$message.info('手机号不能为空');
            return false;
          }
          // if (!validate(this.account, 'phone')) {
          //   this.$message.info('请输入正确的手机号');
          //   return false;
          // }
          // this.account = this.account
        }
        if (!validate(this.code, 'require')) {
          this.$message.info('验证码不能为空');
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        if (!validate(this.password, 'require')) {
          this.$message.info('密码不能为空');
          return false;
        }
        if (!validate(this.password, 'password')) {
          this.$message.info('请输入密码(6~12位字母+数字)');
          return false;
        }
        //请求方法
        //数据验证

        let data5caeeba9866aa = await this.$api.post(global.apiUrls.post5caeeba9866aa, {
          password: this.password,
          account: this.account,
          code: this.code,
          type: '2',
          email: this.account,
          mobile: this.account,
          account_type: this.type,
          area_code: this.area_code
        });

        if (data5caeeba9866aa.data.code != 1) {
          this.$message.info(data5caeeba9866aa.data.msg);
          return
        }



        uni.showToast({
          title: '重置成功',
          mask: true,
          icon: 'none',
          duration: 1500
        });
        setTimeout(() => {
          this.toLoginDiy();
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .myProfile_picker2_0_c2 {
    color: rgba(100, 80, 235, 1);
  }

  .myProfile_picker2_0_c0 {
    color: var(--benbenFontColor2);
  }

  .myProfile_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(image-path('54.png')) no-repeat;
    background-size: 100% auto;
  }

  .forgotPassword_flex_0 {
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
  }

  .forgotPassword_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .forgotPassword_fd0_0_c0 {
    width: 120rpx;
  }

  .forgotPassword_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .forgotPassword_flex_1 {
    padding: 0rpx 56rpx 0rpx 56rpx;
  }

  .forgotPassword_fd1_6_c0 {
    background: rgba(100, 80, 235, 1);
    border-radius: 44rpx;
    width: 638rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .forgotPassword_fd1_6 {
    margin: 78rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_5_c1_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .forgotPassword_fd1_5_c1_icon1 {
    text-align: center;
    font-size: 34rpx;
  }

  ::v-deep .forgotPassword_fd1_5_c1 {
    width: 501rpx;
    font-size: 28rpx;
    height: 32rpx;
    color: rgba(23, 26, 38, 1);
  }

  .forgotPassword_fd1_3_c2 {
    line-height: 32rpx;
    text-align: center;
    font-size: 28rpx;
    color: rgba(23, 26, 38, 1);
    margin: 0rpx 0rpx 0rpx auto;
  }

  .forgotPassword_fd1_3 {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0rpx 3rpx 6rpx 1rpx #F2F5FF;
    background-size: 100% auto;
    border-radius: 44rpx;
    padding: 24rpx 32rpx 24rpx 32rpx;
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_2_c1_c1 {
    width: 14rpx;
    height: 8rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_2_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_2_c1 {
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_1_c1 {
    color: rgba(23, 26, 38, 1);
    font-size: 28rpx;
  }

  .forgotPassword_fd1_1_c0 {
    width: 34rpx;
    height: 34rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 32rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_1 {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0rpx 3rpx 6rpx 1rpx #F2F5FF;
    background-size: 100% auto;
    border-radius: 44rpx;
    padding: 24rpx 32rpx 24rpx 32rpx;
  }

  .forgotPassword_fd1_0_c0 {
    width: 148rpx;
    height: 148rpx;
    border-radius: 33rpx;
  }

  .forgotPassword_fd1_0 {
    margin: 78rpx 0rpx 124rpx 0rpx;
  }
</style>
